package com.twu.biblioteca;

import java.util.ArrayList;
import java.util.List;

public class Movies {
    private List<Movie> movieList = new ArrayList<Movie>();

    public void add(Movie movie) {
        movieList.add(movie);
    }

    public String list() {
        StringBuilder sb = new StringBuilder();
        sb.append(BiblioMessages.MOVIE_LIST);
        for (Movie movie : movieList) {
            sb.append("\n").append(movie.name()).append(", ")
                    .append(movie.year()).append(", ")
                    .append(movie.director()).append(", ")
                    .append(movie.rating());
        }
        return sb.toString();
    }

    public boolean remove(String movieName) {
        for (Movie movie : movieList) {
            if(movieName.equals(movie.name())){
                movieList.remove(movie);
                return true;
            }
        }
        return false;
    }
}
